package com.hmdp.utils;

import com.hmdp.dto.UserDTO;
import com.hmdp.entity.User;

public class UserHolder {
    private static final ThreadLocal<UserDTO> tl = new ThreadLocal<>();

    public static void saveUser(UserDTO user){
        tl.set(user);
    }

    public static UserDTO getUser(){
        return tl.get();
    }

    public static void removeUser(){
        tl.remove();
    }

//    public static UserDTO entity2Dto(User user){
//        UserDTO userDTO = new UserDTO();
//        userDTO.setIcon(user.getIcon());
//        userDTO.setNickName(user.getNickName());
//        userDTO.setId(user.getId());
//        return userDTO;
//    }
}
